﻿@model ProductDetailsModel
@using Nop.Core.Domain.Seo
@inject Nop.Core.IWebHelper webHelper
@inject SeoSettings seoSettings
@{
    Layout = "_ColumnsOne";

    //title
    Html.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
    //meta
    Html.AddMetaDescriptionParts(Model.MetaDescription);
    Html.AddMetaKeywordParts(Model.MetaKeywords);
    //page class
    Html.AppendPageCssClassParts("html-product-details-page");

    //canonical URL
    if (seoSettings.CanonicalUrlsEnabled)
    {
        var productUrl = Url.RouteUrl("Product", new { SeName = Model.SeName }, webHelper.CurrentRequestProtocol).ToLowerInvariant();
        Html.AddCanonicalUrlParts(productUrl, seoSettings.QueryStringInCanonicalUrlsEnabled);
    }

    //open graph META tags
    if (seoSettings.OpenGraphMetaTags)
    {
        Html.AddHeadCustomParts("<meta property=\"og:type\" content=\"product\" />");
        Html.AddHeadCustomParts("<meta property=\"og:title\" content=\"" + Html.Encode(Model.Name) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:description\" content=\"" + Html.Encode(Nop.Core.Html.HtmlHelper.StripTags(Model.MetaDescription)) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:image\" content=\"" + Model.DefaultPictureModel.ImageUrl + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:image:url\" content=\"" + Model.DefaultPictureModel.ImageUrl + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:url\" content=\"" + webHelper.GetThisPageUrl(false) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:site_name\" content=\"" + Html.Encode(Model.CurrentStoreName) + "\" />");
    }

    //Twitter META tags
    if (seoSettings.TwitterMetaTags)
    {
        Html.AddHeadCustomParts("<meta property=\"twitter:card\" content=\"summary\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:site\" content=\"" + Html.Encode(Model.CurrentStoreName) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:title\" content=\"" + Html.Encode(Model.Name) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:description\" content=\"" + Html.Encode(Nop.Core.Html.HtmlHelper.StripTags(Model.MetaDescription)) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:image\" content=\"" + Model.DefaultPictureModel.ImageUrl + "\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:url\" content=\"" + webHelper.GetThisPageUrl(false) + "\" />");
    }
}
<!--product breadcrumb-->
@section Breadcrumb
    {
    @await Html.PartialAsync("_ProductBreadcrumb", Model.Breadcrumb)
}
@await Component.InvokeAsync("Widget", new { widgetZone = PublicWidgetZones.ProductDetailsAfterBreadcrumb, additionalData = Model })
<div class="page product-details-page">
    <div class="page-body">
        @await Component.InvokeAsync("Widget", new { widgetZone = PublicWidgetZones.ProductDetailsTop, additionalData = Model })
        <form asp-route="Product" asp-route-sename="@Model.SeName" method="post" id="product-details-form">
            @if (seoSettings.MicrodataEnabled)
            {
                @await Html.PartialAsync("_Microdata", Model)
            }
            <div data-productid="@Model.Id">
                <div class="product-essential">
                    @await Component.InvokeAsync("Widget", new { widgetZone = PublicWidgetZones.ProductDetailsEssentialTop, additionalData = Model })
                    <!--product pictures-->
                    @await Html.PartialAsync("_ProductDetailsPictures", Model)
                    <div class="overview">
                        @await Html.PartialAsync("_Discontinued", Model)
                        <div class="product-name">
                            <h1>
                                @Model.Name
                            </h1>
                        </div>
                        @if (!string.IsNullOrEmpty(Model.ShortDescription))
                        {
                            <div class="short-description">
                                @Html.Raw(Model.ShortDescription)
                            </div>
                        }
                        @await Component.InvokeAsync("Widget", new { widgetZone = PublicWidgetZones.ProductDetailsOverviewTop, additionalData = Model })
                        <!--product reviews-->
                        @await Html.PartialAsync("_ProductReviewOverview", Model.ProductReviewOverview)
                        <!--product manufacturers-->
                        @await Html.PartialAsync("_ProductManufacturers", Model.ProductManufacturers)
                        <!--compare, email a friend-->
                        <div class="overview-buttons">
                            @await Component.InvokeAsync("Widget", new { widgetZone = PublicWidgetZones.ProductDetailsInsideOverviewButtonsBefore, additionalData = Model })
                            @await Html.PartialAsync("_CompareProductsButton", Model)
                            @await Html.PartialAsync("_ProductEmailAFriendButton", Model)
                            @await Component.InvokeAsync("Widget", new { widgetZone = PublicWidgetZones.ProductDetailsInsideOverviewButtonsAfter, additionalData = Model })
                        </div>
                        @await Html.PartialAsync("_ShareButton", Model)
                        @await Component.InvokeAsync("Widget", new { widgetZone = PublicWidgetZones.ProductDetailsOverviewBottom, additionalData = Model })
                    </div>
                    @if (!string.IsNullOrEmpty(Model.FullDescription))
                    {
                        <div class="full-description">
                            @Html.Raw(Model.FullDescription)
                        </div>
                    }
                    @await Component.InvokeAsync("Widget", new { widgetZone = PublicWidgetZones.ProductDetailsEssentialBottom, additionalData = Model })
                </div>
                @await Component.InvokeAsync("Widget", new { widgetZone = PublicWidgetZones.ProductDetailsBeforeCollateral, additionalData = Model })
                <div class="product-collateral">
                    <!--associated products-->
                    <div class="product-variant-list">
                        @foreach (var variant in Model.AssociatedProducts)
                        {
                            <div class="product-variant-line" data-productid="@variant.Id">
                                @if (!string.IsNullOrWhiteSpace(variant.DefaultPictureModel.ImageUrl))
                                {
                                    <div class="variant-picture">
                                        <img alt="@variant.DefaultPictureModel.AlternateText" src="@variant.DefaultPictureModel.ImageUrl"
                                             title="@variant.DefaultPictureModel.Title" id="main-product-img-@variant.Id" />
                                    </div>
                                }
                                <div class="variant-overview">
                                    @if (!string.IsNullOrWhiteSpace(variant.Name))
                                    {
                                        <div class="variant-name">
                                            @variant.Name
                                        </div>
                                    }
                                    @if (!string.IsNullOrWhiteSpace(variant.ShortDescription))
                                    {
                                        <div class="variant-description">
                                            @Html.Raw(variant.ShortDescription)
                                        </div>
                                    }
                                    <!--availability-->
                                    @await Html.PartialAsync("_Availability", variant)
                                    <!--SKU, MAN, GTIN, vendor-->
                                    @await Html.PartialAsync("_SKU_Man_GTIN_Ven", variant)
                                    <!--delivery-->
                                    @await Html.PartialAsync("_DeliveryInfo", variant)
                                    <!--sample download-->
                                    @await Html.PartialAsync("_DownloadSample", variant)
                                    <!--attributes-->
                                    @{
                                        var dataDictAttributes = new ViewDataDictionary(ViewData);
                                        dataDictAttributes.TemplateInfo.HtmlFieldPrefix = $"attributes_{variant.Id}";
                                        @await Html.PartialAsync("_ProductAttributes", variant.ProductAttributes, dataDictAttributes)
                                    }
                                    <!--gift card-->
                                    @{
                                        var dataDictGiftCard = new ViewDataDictionary(ViewData);
                                        dataDictGiftCard.TemplateInfo.HtmlFieldPrefix = $"giftcard_{variant.Id}";
                                        @await Html.PartialAsync("_GiftCardInfo", variant.GiftCard, dataDictGiftCard)
                                    }
                                    <!--rental info-->
                                    @{
                                        var dataDictRental = new ViewDataDictionary(ViewData);
                                        dataDictRental.TemplateInfo.HtmlFieldPrefix = $"rental_{variant.Id}";
                                        @await Html.PartialAsync("_RentalInfo", variant, dataDictRental)
                                    }
                                    <!--price & add to cart-->
                                    @{
                                        var dataDictPrice = new ViewDataDictionary(ViewData);
                                        dataDictPrice.TemplateInfo.HtmlFieldPrefix = $"price_{variant.Id}";
                                        @await Html.PartialAsync("_ProductPrice", variant.ProductPrice, dataDictPrice)
                                    }
                                    <!--price breaks-->
                                    @await Html.PartialAsync("_ProductTierPrices", variant.TierPrices)
                                    @{
                                        var dataDictAddToCart = new ViewDataDictionary(ViewData);
                                        dataDictAddToCart.TemplateInfo.HtmlFieldPrefix = $"addtocart_{variant.Id}";
                                        @await Html.PartialAsync("_AddToCart", variant.AddToCart, dataDictAddToCart)
                                    }
                                    <!--estimate shipping-->
                                    @{
                                        var dataDictEstimateShipping = new ViewDataDictionary(ViewData);
                                        dataDictEstimateShipping.TemplateInfo.HtmlFieldPrefix = $"estimate_shipping_{variant.Id}";
                                        @await Html.PartialAsync("_ProductEstimateShipping", variant.ProductEstimateShipping, dataDictEstimateShipping)
                                    }
                                    <!--wishlist-->
                                    @{
                                        var dataDictAddToWishlist = new ViewDataDictionary(ViewData);
                                        dataDictAddToWishlist.TemplateInfo.HtmlFieldPrefix = $"addtocart_{variant.Id}";
                                        @await Html.PartialAsync("_AddToWishlist", variant.AddToCart, dataDictAddToWishlist)
                                    }
                                </div>
                            </div>
                        }
                        @if (Model.AssociatedProducts.Count == 0)
                        {
                            <div class="no-associated-products">
                                @T("Products.NoAssociatedProducts")
                            </div>
                        }
                    </div>
                    @await Html.PartialAsync("_ProductSpecifications", Model.ProductSpecifications)
                    @await Html.PartialAsync("_ProductTags", Model.ProductTags)
                </div>
                @*we do not display "also purchased" for grouped products
                    @await Component.InvokeAsync("ProductsAlsoPurchased", new { productId = Model.Id })*@
                @await Component.InvokeAsync("RelatedProducts", new { productId = Model.Id })
            </div>
        </form>
        @await Component.InvokeAsync("Widget", new { widgetZone = PublicWidgetZones.ProductDetailsBottom, additionalData = Model })
    </div>
</div>
